package com.yl.module.user.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDate;

/**
 * <p>
 * 前台 - 用户表
 * </p>
 *
 * @author jiangtao
 * @since 2020-04-21
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("cms_user")
public class User extends Model<User> {

    public static final String TABLE = "cms_user";

    private static final long serialVersionUID = 1L;

    /**
     * 账号
     */
    @Excel(name = "账号", width = 15, isImportField = "true_st", orderNum = "2")
    @NotNull(message = "不能为空")
    @TableField("account")
    private String account;

    /**
     * 昵称
     */
    @Excel(name = "名字", width = 15, isImportField = "true_st", orderNum = "2")
    @NotNull(message = "不能为空")
    @TableField("nickname")
    private String nickname;

    /**
     * 密码
     */
    @Excel(name = "密码", width = 30, isImportField = "true_st", orderNum = "2")
    @NotNull(message = "不能为空")
    @Pattern(regexp="^[0-9a-zA-Z!@#$%^&*]{6,18}$",message="格式不正确")
    @TableField("password")
    private String password;

    @TableField(exist = false)
    private String confirmPassword;

    /**
     * 盐
     */
    @TableField("salt")
    private String salt;

    /**
     * 手机号码
     */
    @Excel(name = "手机号码", width = 20, isImportField = "true_st", orderNum = "2")
    @Pattern(regexp = "(^1[0-9]{10}$)", message = "不合法")
    @NotNull(message = "不能为空")
    @TableField("mobile")
    private String mobile;

    /**
     * 邮箱
     */
    @TableField("email")
    private String email;

    /**
     * 真实姓名
     */
    @TableField("real_name")
    private String realName;

    /**
     * 身份证
     */
    @Excel(name = "身份证号码", width = 25, isImportField = "true_st", orderNum = "2")
    @NotNull(message = "不能为空")
    @Pattern(regexp = "(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{2}$)", message = "不合法")
    @TableField("id_card")
    private String idCard;

    /**
     * 年龄
     */
    @Excel(name = "年龄", width = 10, orderNum = "2")
    @Range(min=15, max=150, message = "在15-150岁中间")
    @TableField("age")
    private Integer age;

    /**
     * 出生年月
     */
    @Excel(name = "出生年月", width = 15, format = "yyyy-MM-dd", orderNum = "2")
    @TableField("birthday")
    private LocalDate birthday;

    /**
     * 性别
     */
    @Excel(name = "性别", width = 10, replace = {"男_1", "女_2", "_3"}, addressList = true, orderNum = "2")
    @TableField("gender")
    private Integer gender;
    @TableField(exist = false)
    private String genderName;

    /**
     * 区
     */
    //@Excel(name = "区", orderNum = "2")
    @TableField("district")
    private String district;

    @TableField(exist = false)
    private String districtName;

    /**
     * 街道
     */
    //@Excel(name = "街道", orderNum = "2")
    @TableField("street")
    private String street;

    @TableField(exist = false)
    private String streetName;

    /**
     * 居委
     */
    @Excel(name = "居委", width = 20, orderNum = "2")
    @TableField("committee")
    private String committee;

    @TableField(exist = false)
    private String committeeName;

    /**
     * 地址
     */
    @Excel(name = "居住地址", width = 30, orderNum = "2")
    @TableField("address")
    private String address;

    /**
     * 户籍地代码
     */
    //@Excel(name = "户籍地代码", orderNum = "2")
    @TableField("region_reg")
    private String regionReg;
    /**
     * 户籍地
     */
    @TableField("region_name_reg")
    private String regionNameReg;
    @TableField(exist = false)
    private String provinceReg;
    @TableField(exist = false)
    private String cityReg;
    @TableField(exist = false)
    private String districtReg;
    @TableField(exist = false)
    private String streetReg;

    /**
     * 户籍类型
     */
    @Excel(name = "户籍类型", width = 20, replace = {"本区本镇_1", "本区外镇_2", "外区外镇_3", "上海以外_4", "_9"}, addressList = true, orderNum = "2")
    @TableField("house_reg_type")
    private Integer houseRegType;
    @TableField(exist = false)
    private String houseRegTypeName;

    /**
     * 头像
     */
    @TableField("avatar")
    private String avatar;

    /**
     * 账号状态
     */
    @TableField("status")
    private Integer status;
    @TableField(exist = false)
    private String statusName;


}
